package HomeWork;

import java.util.Scanner;

/*
7.模拟计算器功能，对键盘录入的两个int类型的数据
进行加、减、乘、除的运算，并打印运算结果。
 */
public class Test07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入第一个整数：");
        int a = sc.nextInt();

        System.out.println("请输入第二个整数：");
        int b = sc.nextInt();

        int c;
        do{
            System.out.println("请输入您要进行的运算（1：表示加法，2：表示减法，3：表示乘法，4：表示除法）");
            c = sc.nextInt();
            if(c < 1 || c > 4){
                System.out.println("输入错误，请重新输入：");
                System.out.println("-------------------");
            }else{
                break;
            }
        }while(true);

        switch (c){
            case 1:
                System.out.println(a + " + " + b + " = " + (a+b));
                break;
            case 2:
                System.out.println(a + " - " + b + " = " + (a-b));
                break;
            case 3:
                System.out.println(a + " * " + b + " = " + (a*b));
                break;
            default:
                System.out.println(a + " ÷ " + b + " = " + ((double)a/b));
                break;
        }

    }
}
